<?php
namespace services\logic;

require_once 'core/extra_time_logic.php';
require_once 'core/historical_data_lookup.php';
require_once 'core/stock_check.php';
require_once 'core/supplier_lead_time_logic.php';
require_once 'core/interface_logic.php';

use services\logic\core as core;


class logic {
    
    private $_logics = array();

    public function __construct($logics = array()) {
       
        foreach ($logics as $logic) {
            if($logic instanceof core\interface_logic){
                $this->_logics[] = $logic;
            }
        }       
    }
    
    public function get_time(){
        $time = 0;
        foreach ($this->_logics as  $logic) {
            $time += $logic->get_time();
        }
        return $time;
    }

    public function &__get($logic_name) {
        foreach ($this->_logics as &$logic) {
            $ar_class = explode('\\', get_class($logic));
            if(end($ar_class) === $logic_name){
                return $logic;
            }
        }
        return null;
    }

}
?>
